﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JJY.DBUtility;
using System.Data;
using System.Data.SqlClient;
using Odds.Utility;

namespace Odds.DBUtility
{
    public class OddsSQLEntityHelper<T> : SQLEntityHelper<T> where T : class
    {
        public static T GetEntity(string sql, params SqlParameter[] commandParameters)
        {
            return GetEntitySet(AppSettingManager.OddsConnectionString, sql, commandParameters).FirstOrDefault();
        }

        public static List<T> GetEntitySet(CommandType commandType, string sql, params SqlParameter[] commandParameters)
        {
            return GetEntitySet(AppSettingManager.OddsConnectionString, commandType, sql, commandParameters);
        }

        public static List<T> GetEntitySet(string sql, params SqlParameter[] commandParameters)
        {
            return GetEntitySet(SQLHelper.ExecuteReader(AppSettingManager.OddsConnectionString,
                                                            CommandType.Text, sql, commandParameters));
        }
    }
}
